package cn.hdustea.shopNavigation.config

import android.text.TextUtils
import com.hdustea.base.util.SPUtil

/**
 * <pre>
 *     author : HuQiang
 *     time   : 2020/09/25
 *     desc   :
 *     version: 1.0
 * </pre>
 */
class ConfigKey {
    companion object {
        private val GLOBAL_LOCATION = "global_location"
        private val CITY_MARKETS_SELECT = "city_market_select"
        private val SEARCH_HISTORY = "search_history"
        private val USER_ID = "user_id"  /* 用户Id */
        private val USER_NAME = "user_name";  /* 用户名 */
        private val USER_PHONE = "user_phone"  /* 用户手机号 */
        private val USER_PORTRAIT = "user_portailt" /* 用户头像 */

        fun setGlobalLocation(location: String?) = SPUtil.put(GLOBAL_LOCATION, location)
        fun getGlobalLocation(): String = SPUtil.getString(GLOBAL_LOCATION)
        fun setCityMarketsSelect(cityMarkets: String) = SPUtil.put(CITY_MARKETS_SELECT, cityMarkets)
        fun getCityMarketsSelect(): String = SPUtil.getString(CITY_MARKETS_SELECT)
        fun setSearchHistory(history: String?) = SPUtil.put(SEARCH_HISTORY, history)
        fun getSearchHistory(): String = SPUtil.getString(SEARCH_HISTORY)
        fun isLogin() = !TextUtils.isEmpty(getUserId())
        fun setUserId(userId: String) = SPUtil.put(USER_ID, userId)
        fun getUserId() = SPUtil.getString(USER_ID)
        fun setUserName(userName: String) = SPUtil.put(USER_NAME, userName)
        fun getUserName() = SPUtil.getString(USER_NAME)
        fun setUserPhone(phoneNum: String) = SPUtil.put(USER_PHONE, phoneNum)
        fun getUserPhone() = SPUtil.getString(USER_PHONE)
        fun setUserPortrait(url: String) = SPUtil.put(USER_PORTRAIT, url)
        fun getUserPortrait() = SPUtil.getString(USER_PORTRAIT)

        fun clearUserInfo() {
            setUserId("")
            setUserName("")
            setUserPhone("")
            setUserPortrait("")
        }
    }
}